<?php

namespace app\admin\controller;

use app\common\controller\AdminBaseController;

class AdminController extends AdminBaseController
{
    protected function initialize()
    {
        parent::initialize();
        $this->server = model('server.admin');
    }

    public function getAdminListPageOp()
    {
        $requestData = validateRequestParam('admin', 'getListPage');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('GET_SUCCESS')];
        $responseData['data'] = $this->server->getListPage($requestData);

        return $responseData;
    }

    public function saveAdminAddOp()
    {
        $requestData = validateRequestParam('admin', 'saveAdd');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('SAVE_SUCCESS')];
        $responseData['data'] = $this->server->saveAdd($requestData);

        return $responseData;
    }

    public function getAdminRowOp()
    {
        $requestData = validateRequestParam('admin', 'getRow');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('GET_SUCCESS')];
        $responseData['data'] = $this->server->getRow($requestData);

        return $responseData;
    }

    public function saveAdminEditOp()
    {
        $requestData = validateRequestParam('admin', 'saveEdit');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('SAVE_SUCCESS')];
        $responseData['data'] = $this->server->saveEdit($requestData);

        return $responseData;
    }

    public function saveAdminDelOp()
    {
        $requestData = validateRequestParam('admin', 'saveEdit');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('DEL_SUCCESS')];
        $responseData['data'] = $this->server->saveDel($requestData);

        return $responseData;
    }

    public function getAdminInfoOp()
    {
        $responseData['meta'] = ['code' => 1, 'msg' => lang('DEL_SUCCESS')];
        $responseData['data'] = $this->server->getInfo();

        return $responseData;
    }

    public function saveAdminInfoOp()
    {
        $requestData = validateRequestParam('admin', 'saveInfo');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('SAVE_SUCCESS')];
        $responseData['data'] = $this->server->saveInfo($requestData);

        return $responseData;
    }

    public function setAdminPasswordOp()
    {
        $requestData = validateRequestParam('admin', 'setPassword');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('SAVE_SUCCESS')];
        $responseData['data'] = $this->server->setPassword($requestData);

        return $responseData;
    }

    public function saveAdminPowerOp()
    {
        $requestData = validateRequestParam('admin', 'savePower');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('SAVE_SUCCESS')];
        $responseData['data'] = $this->server->savePower($requestData);

        return $responseData;
    }

    public function getAdminPowerOp()
    {
        $requestData = validateRequestParam('admin', 'getRow');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('GET_SUCCESS')];
        $responseData['data'] = $this->server->getPower($requestData);

        return $responseData;
    }
}
